<script>
import base from './form/index'
import $ from '@/common'
export default {
  extends: base,
  subModuleStore: true,
  data() {
    return {
      formDefaultData: {}
    }
  },
  computed: {
    dataPath(v) {
      if (this.actionParam.bill_code || this.actionParam.pathData) {
        return $.composePath(this.actionParam.path_data || this.path.def, {
          bill_code: this.actionParam.bill_code,
          ...this.triggerData.data
        });
      }
    }
  },
  methods: {
    onActive() {
      this.$dispatch("form/restoreDefault", this.formDefaultData)
    },
    setData(data) {
      this.formDefaultData = data
      this.actionActive();
    },
    setModel(model) {
      this.setFormModel(model)
      this.formDefaultData = model.data
      this.actionActive();
    },
    formSubmit() {
      if (this.local) {
        return new Promise((resolve) => {
          this.$owner.addRow(this.formData)
          resolve()
        })
      } else {
        return this.formPut();
      }
    }
  },
  created() {}
}
</script>
